import { httpGet, postFile } from '../common/util'

/**
 * 获取组件列表
 */
export const getComponents = (repository, continuationToken) => {
  let url = `/v1/components?repository=${repository}`;
  if (continuationToken !== '' && continuationToken !== null) {
    url = url + `&continuationToken=${continuationToken}`
  }
  return httpGet({ url })
}

/**
 * 上传一个包的方法
 */
export const upload = (repository, filePath, fileName, dataKey = 'npm.asset') => {
  return postFile(`/v1/components?repository=${repository}`, filePath, fileName, dataKey);
}
